import 'package:flutter/material.dart';
import 'package:lite_message/ui/root/login/login_page.dart';
import 'package:lite_message/util/app_util.dart';
import 'package:lite_message/widgets/logo.dart';

///闪屏页
class SplashPage extends StatefulWidget {
  const SplashPage({Key key}) : super(key: key);
  @override
  _SplashPageState createState() => _SplashPageState();
}

class _SplashPageState extends State<SplashPage> {
  @override
  void initState() {
    super.initState();

    LM.hideStatusBar();

    _ready();
  }

  @override
  void dispose() {
    LM.showStatusBar();

    print('object dispose');

    super.dispose();
  }

  ///准备
  _ready() async {
    await Future.delayed(const Duration(seconds: 2), () {
      LM.jump(context, const LoginPage(), isRemove: true);
    });
  }

  @override
  Widget build(BuildContext context) {
    LM.initScreen(context);

    return WillPopScope(
      onWillPop: () async => Future.value(false),
      child: Scaffold(
        backgroundColor: Theme.of(context).accentColor,
        body: Center(
          child: Logo(color: Theme.of(context).bottomAppBarColor),
        ),
      ),
    );
  }
}
